totalreport = {
  initPage:function() {
    this.data = {
      pageNum: 1,
      searchType: 0,
      queryData: {
        page: 1,
        size: 10,
        areaId: '',
        platformId: '',
        owersId: '',
        vehicleNo: '',
        driverName: '',
        dateType: '',
        startTime: '',
        endTime: '',
        safeReportType: 1 // 企业 1  车辆 2
      },
      carData: {
        page: 1,
        size: 5,
				platformName: '', //平台模糊
				owersName: '', //企业模糊
				vehicleNo: '', //车牌号模糊
				areaId: '', //地区code
				state: '', //分配 未分配
      },
      attr: [],
      tableData: [],
      reportTotalTableData: [],
      currentSafetyReportPage: 1,
      columnsDataPlat: [
        {
          field: 'no',
          title: '序号',
          align: 'center',
          formatter: function (value, row, index) {
            var pageSize = totalreport.data.queryData.size;     //每页多少条
            var pageNumber = totalreport.data.queryData.page; //当前第几页
            return pageSize * (pageNumber - 1) + index + 1;    // 返回每条的序号： 每页条数 *（当前页 - 1 ）+ 序号
          }
        },
        {
          field: "statisticsTime",
          title: "统计时间",
          align: 'center',
        },
        {
          field: "owersName",
          title: "分析对象",
          align: 'center',
        },
        {
          field: "analysisReport",
          title: "报告名称",
          align: 'center',
        },
        {
          field: "platformName",
          title: "所属运营商",
          align: 'center',
        },
        {
          field: "areaName",
          title: "所属地区",
          align: 'center',
        },
        {
          field: "dayTime",
          title: "生成时间",
          align: 'center',
        },
        {
          field: 'Button',
          title: '操作',
          width: "150",
          align: 'center',
          events: operateEventsPlat,
        }
      ],
      columnsDataVeh: [
        {
          field: 'no',
          title: '序号',
          align: 'center',
          formatter: function (value, row, index) {
            var pageSize = totalreport.data.queryData.size;     //每页多少条
            var pageNumber = totalreport.data.queryData.page; //当前第几页
            return pageSize * (pageNumber - 1) + index + 1;    // 返回每条的序号： 每页条数 *（当前页 - 1 ）+ 序号
          }
        },
        {
          field: "statisticsTime",
          title: "统计时间",
          align: 'center',
        },
        {
          field: "owersName",
          title: "分析对象",
          align: 'center',
        },
        {
          field: "analysisReport",
          title: "报告名称",
          align: 'center',
        },
        {
          field: "platformName",
          title: "所属运营商",
          align: 'center',
        },
        {
          field: "areaName",
          title: "所属地区",
          align: 'center',
        },
        {
          field: "owersName",
          title: "企业/业户",
          align: 'center',
        },
        {
          field: "dayTime",
          title: "生成时间",
          align: 'center',
        },
        {
          field: 'Button',
          title: '操作',
          width: "150",
          align: 'center',
          events: operateEventsVehicle,
        }
      ],
      columnsDataDriver: [
        {
          field: 'no',
          title: '序号',
          align: 'center',
          formatter: function (value, row, index) {
            var pageSize = totalreport.data.queryData.size;     //每页多少条
            var pageNumber = totalreport.data.queryData.page; //当前第几页
            return pageSize * (pageNumber - 1) + index + 1;    // 返回每条的序号： 每页条数 *（当前页 - 1 ）+ 序号
          }
        },
        {
          field: "statisticsTime",
          title: "统计时间",
          align: 'center',
        },
        {
          field: "owersName",
          title: "分析对象",
          align: 'center',
        },
        {
          field: "analysisReport",
          title: "报告名称",
          align: 'center',
        },
        {
          field: "platformName",
          title: "所属运营商",
          align: 'center',
        },
        {
          field: "areaName",
          title: "所属地区",
          align: 'center',
        },
        {
          field: "dayTime",
          title: "生成时间",
          align: 'center',
        },
        {
          field: 'Button',
          title: '操作',
          width: "150",
          align: 'center',
          events: operateEventsDriver,
        }
      ],
      columnsSafetyReportTotal: [
        {
          field: 'statisticsTime',
          title: '报告统计时间',
          align: 'center',
          // width: '100'
        },
        {
          field: 'vehicleNo',
          title: '分析对象',
          align: 'center',
          // width: '80'
        },
        {
          field: 'areaName',
          title: '所属地区',
          align: 'center',
          // width: '150'
        },
        {
          field: 'platformName',
          title: '运营商平台',
          align: 'center',
          // width: '150'
        },
        {
          field: 'vehicleNum',
          title: '分析总车辆数',
          align: 'center',
          // width: '250'
        },
        {
          field: 'activeNum',
          title: '主动安全报警数',
          align: 'center',
          // width: '150'
        },
        {
          field: 'accidentNum',
          title: '事故报警数',
          align: 'center',
          // width: '150'
        },
        {
          field: 'illegalNum',
          title: '违规报警数',
          align: 'center',
          // width: '150'
        },
        {
          field: 'alarmNum',
          title: '报警总数',
          align: 'center',
          // width: '80'
        },
        {
          field: 'handleResult',
          title: '报警处理数',
          align: 'center',
          // width: '200'
        },
        {
          field: 'handleLv',
          title: '报警处理率',
          align: 'center',
          // width: '100'
        }     
      ],
      columnsSafetyReportDetail: [],
      columusSelectVehicleNo:[ // 模态框table
        {
				field: 'check',
        radio: true,
        align: 'center',
				width: "60"
        },
        {
          field: 'no',
          title: '序号',
          align: 'center',
          formatter: function (value, row, index) {
            var pageSize = totalreport.data.carData.size;     //每页多少条
            var pageNumber = totalreport.data.carData.page; //当前第几页
            return pageSize * (pageNumber - 1) + index + 1;    // 返回每条的序号： 每页条数 *（当前页 - 1 ）+ 序号
          }
        },
        {
          field: "vehicleNo",
          title: "车牌号码",
          align: 'center',
        },
        {
          field: "areaName",
          title: "地区",
          align: 'center',
        },
        {
          field: "platformName",
          title: "运营商平台",
          align: 'center',
        },
        {
          field: "owersName",
          title: "企业",
          align: 'center',
        }
		  ],
      safetyReportDetailData: []
    }
    this.initTime();
    this.btnEvent();
    this.getOwerReportTable(); // 初始化table
    this.selectInputInit(); // 地区
    this.selectedValue(); // select 样式
  },
  /**
   * 地区input级联选择 数据获取
   */
  selectInputInit() {
    jrequest.get("/api/assessMent/selectByArea",{}).then(res => {
      var data = res.data;
      data[0].code=1;
				$.each(data[0].cityAreaVOS,function(i,dom){
					data[0].cityAreaVOS[i].code=2;
					$.each(data[0].cityAreaVOS[i].cityAreaVOS,function(j,dom){
						data[0].cityAreaVOS[i].cityAreaVOS[j].code=3;
					})
				})
				this.creatMainRido("qrm-main",data,"cityAreaVOS","code");
    })
  },
  creatMainRido:function(id,attr,child,jibie){
		$(id).html("");
		var sttrdiv="";
		for(var i=0;i<3;i++){
			sttrdiv +="<div class='qrm-border"+(i+1)+"' style='display:none'>"+
				"<ul class='qrm-lev-"+(i+1)+" qrm-lev' id='qrm-border1'>"+
				"</ul>"+
				"</div>"
		};
		$(".qrm-main").html(sttrdiv);
		var str="";
		$("#qrm-border1").html("");
		var forTree = function(o){
			for(var i=0;i<o.length;i++){
				var urlstr = "";
				try{
					urlstr = "<li><span data-id='"+o[i]["id"]+"'>"+ o[i]["name"] +"</span><i class='qrm-arrow-right'></i><ul class='li-zi-"+o[i][jibie]+"' style='display: none'>";
					str += urlstr;
					if(o[i][child] != null){
						forTree(o[i][child]);
					}
					str += "</ul>";
				}catch(e){}
			}
			return str;
		};
		$("#qrm-border1").html(forTree(attr));
  },
  /**
   * 时间初始化
   */
  initTime() {
    //选择月
    var monthDefault = moment().subtract(1, 'months').format('YYYY-MM');
    var yearDefault = moment().subtract(1, 'year').format('YYYY');
    $('.J-yearMonthPicker-single').datePicker({
      format: 'YYYY-MM',
      // min: '2018-01',
      max: monthDefault,
      hide: function (type) {
        console.info(this.$input.eq(0).val());
      }
    });
    //选择年
    $('.J-yearPicker-single').datePicker({
      format: 'YYYY',
      // min: '2018',
      max: yearDefault
    });
    $(".J-yearPicker-single").hide();
  },
  /**
   * 获取查询参数
   */
  getQueryData() {
    let type = $("#reportStaticTime").val() || "月";
    let queryTableData = {};
    let dateTime = "";
    let dateTimeType = ""; // 按月查询
    if (type === "年") {
      dateTime = $("#samplingTimeY").val();
      dateTimeType = "5";
    } else if (type === "月") {
      dateTime = $("#samplingTimeM").val();
      dateTimeType = "3";
    }
    if (this.data.pageNum === 1) {
      queryTableData = {
        page: this.data.queryData.page,
        size: this.data.queryData.size,
        areaId: $(".j-search-row .item").eq(0).find("input").attr("data-id") || "",
        platformId: $(".platform_name select").val(),
        owersId: $(".owers_name select").val(),
        time: dateTime,
        dateType: "",
        safeReportType: 1
      }
    } else if (this.data.pageNum === 2) {
      queryTableData = {
        page: this.data.queryData.page,
        size: this.data.queryData.size,
        areaId: $(".j-search-row .item").eq(0).find("input").attr("data-id") || "",
        platformId: $(".platform_name select").val(),
        owersId: $(".owers_name select").val(),
        vehicleNo: $("#report_vehicleS").val(), // 待修改
        time: dateTime,
        dateType: "",
        safeReportType: 2,
      }
    } else if (this.data.pageNum === 3) {
      queryTableData = {
        page: this.data.queryData.page,
        size: this.data.queryData.size,
        areaId: $(".j-search-row .item").eq(0).find("input").attr("data-id") ||  "",
        platformId: $(".platform_name select").val(),
        owersId: $(".owers_name select").val(),
        driverName: $(".report_driverS select").val(), // 待修改
        time: dateTime,
        dateType: ""
      }
    }
    if (this.data.searchType === 1) {
      queryTableData.dateType = dateTimeType;
    } else {
      queryTableData.dateType = "";
    }
    return queryTableData;
  },
  resetQueryData() { // 重置
    this.data.queryData.page = 1;
    if (this.data.pageNum === 1) {
      this.data.queryData.safeReportType = 1;
    } else if (this.data.pageNum === 2) {
      this.data.queryData.safeReportType = 2;
    }
    this.data.queryData.areaId = $(".j-search-row .item").eq(0).find("input").attr("data-id","");
    $(".qrm-input").val('');
    $(".platform_name.item .combo-select .combo-input").val('全部');
    $(".owers_name.item .combo-select .combo-input").val('全部');
    $(".driver_name.item .combo-select .combo-input").val('全部'); // 待修改
    this.data.queryData.platformId = $(".platform_name select").val('');
    this.data.queryData.owersId = $(".owers_name select").val('');
    this.data.queryData.vehicleNo = $("#report_vehicleS").val("");// 待修改 车牌号重置
    this.data.queryData.driverName = $(".driver_name select").val(''); // 待修改 司机姓名重置
    // 时间选择 重置
    $("#samplingTimeM").val("");
    $("#samplingTimeY").val("");
    $("#reportStaticTime").val("月")
    $(".select_MYtime .combo-select .combo-input").val("月");
    $(".J-yearPicker-single").hide();
    $(".J-yearMonthPicker-single").show();
  },
  /**
   * 表格 bootstrap table 初始化
   */
  initBootTable(data,columns,total) {
    data.forEach(item => {
      item.Button = this.operateFormatter()
    })
    $('#cnf_reportTable').bootstrapTable({
      method: 'get',
      cache: false,
      height: 420,
      pagination: true,
      pageSize: totalreport.data.queryData.size,
      pageNumber:totalreport.data.queryData.page,
      pageList: [10, 25, 50, 100],
      showColumns: true,
      striped: true,
      columns: columns,
      data :data,
      sidePagination: 'server', // client or server
      totalRows: total,
      onPageChange: function (size, number) {
        totalreport.data.queryData.size = size;
        totalreport.data.queryData.page = number;
        totalreport.queryTableData();
      },
      formatNoMatches: function(){
          return '暂无数据';
      }
    });
  },
  initSelectCarTable(data,columns,total) {
    $("#dialog_table").bootstrapTable('destroy');
    $('#dialog_table').bootstrapTable({
      method: 'get',
      cache: false,
      height: 200,
      pagination: true,
      pageSize: totalreport.data.carData.size,
      pageNumber:totalreport.data.carData.page,
      pageList: [10, 25, 50, 100],
      showColumns: true,
      striped: true,
      columns: columns,
      data :data,
      sidePagination: 'server', // client or server
      totalRows: total,
      onPageChange: function (size, number) {
        totalreport.data.carData.size = size;
        totalreport.data.carData.page = number;
        totalreport.getSelectCarTatbleData();
      },
      formatNoMatches: function(){
          return '暂无数据';
      }
    });
  },
  getOwerReportTable() { // 企业
    jrequest.get("/api/safeReport/owersSafetyReport",this.getQueryData()).then(res => {
      $("#cnf_reportTable").bootstrapTable('destroy');
      this.initBootTable(res.data.records,this.data.columnsDataPlat,res.data.total);
    })
  },
  getVehicleReportTable() { // 车辆
    jrequest.get("/api/safeReport/owersSafetyReport",this.getQueryData()).then(res => {
      $("#cnf_reportTable").bootstrapTable('destroy');
      this.initBootTable(res.data.records,this.data.columnsDataVeh,res.data.total);
    })
  },
  getDriverReportTable() { // 驾驶员
    $("#cnf_reportTable").bootstrapTable('destroy');
    this.initBootTable(this.data.tableData,this.data.columnsDataDriver,0);
  },
  queryTableData() {
    switch(this.data.pageNum) {
      case 1:
        this.getOwerReportTable();
        break;
      case 2:
        this.getVehicleReportTable();
        break;
      case 3:
        this.getDriverReportTable();
        break;
    }
  },
  operateFormatter(value,row,index) {
    return [
      '<button type="button" id="table_detail">详情</button>',
      '<button type="button" id="table_delete">删除</button>',
    ].join('');
  },
  /**
   * select 下拉设置
   */
  selectedValue:function(){
		var self=this;
    var optionArr1=["月","年"];
    self.creatId("#reportStaticTime",optionArr1);
    // 平台
    var platformArr = [];
    platformArr[0] = {id: "",name: "全部"};
    jrequest.get("/api/assessMent/selectPlatformAll",{}).then(res => {
      res.data.forEach(item => {
        var obj = {};
        obj.id = item.id;
        obj.name = item.name;
        platformArr.push(obj);
      })
      self.creatIdName("#report_platformS",platformArr);
    })
    // 企业
    var owersArr = [];
    owersArr[0] = {id: "",name: "全部"};
    jrequest.get("/api/owsers/listOwers",{}).then(res => {
      res.data.forEach(item => {
        var obj = {};
        obj.id = item.id;
        obj.name = item.owersName;
        owersArr.push(obj);
      })
      self.creatIdName("#report_owersS",owersArr);
    })
    // 驾驶员
    var driverArr = [];
    driverArr[0] = {id: "",name: "全部",};
    self.creatIdName("#report_driverS",driverArr);
    // jrequest.get("",{}).then(res => {
    //   console.log("驾驶员下拉") // 暂无接口
    //   console.log(res.data)
    // })
	},
	creatId:function(id,optionArr){
		$(id).html();
		var str="";
		$.each(optionArr,function (i) {
			str+="<option value='"+optionArr[i]+"'>"+optionArr[i]+"</option>"
		});
		$(id).html(str);
		$(id).comboSelect();
  },
	creatIdName:function(id,optionArr){
		$(id).html();
		var str="";
		$.each(optionArr,function (i,item) {
			str+="<option value='"+item.id+"'>"+item.name+"</option>"
		});
		$(id).html(str);
		$(id).comboSelect();
  },
  /**
   * 企业 车辆 安全报告设置
   */
  getOwersTotalTableData() { // 总表格
    var self = this;
    $("#report_total_table").bootstrapTable('destroy');
    $('#report_total_table').bootstrapTable({
        method: 'get',
        cache: false,
        height: 420,
        pagination: false,
        pageSize: 10,
        pageNumber:1,
        pageList: [10, 25, 50, 100],
        showColumns: false,
        striped: true,
        columns: self.data.columnsSafetyReportTotal,
        data :self.data.reportTotalTableData,
        sidePagination: 'server', // client or server
        // totalRows: total,
        onPageChange: function (size, number) {

        },
        formatNoMatches: function(){
            return '暂无数据';
        }
      });
  },
  getOwersDetailTableData() { // 详情表格
    var self = this;
    $("#report_detail_table").bootstrapTable('destroy');
    $('#report_detail_table').bootstrapTable({
      method: 'get',
      cache: false,
      height: 420,
      pagination: false,
      pageSize: 10,
      pageNumber:1,
      pageList: [10, 25, 50, 100],
      showColumns: false,
      striped: false,
      hover: false,
      columns: self.data.columnsSafetyReportDetail,
      data :self.data.safetyReportDetailData,
      // sidePagination: 'server', // client or server
      // totalRows: total,
      onPageChange: function (size, number) {

      },
      onLoadSuccess: function(data) {
        
      },
      formatNoMatches: function(){
          return '暂无数据';
      }
    });
    this.mergeRowCollSpan(self.data.safetyReportDetailData);
  },
  getTotalTableColumns(data) { // 详情表格列头数据获取
    var coldata = Object.keys(data[0]);
    var vn = 1;
    for(var i = 0;i < coldata.length;i++) {
      for(var j = 0;j<coldata.length;j++) {
        if (Number(coldata[j]) === vn) {
          var obj = {};
          obj.field = coldata[j];
          obj.title = coldata[j];
          obj.align = "center";
          this.data.columnsSafetyReportDetail[vn + 1] = obj;
        }
      }
      vn+=1;
    }
    for(var i = 0;i < coldata.length;i++) {
      var obj = {};
      if (coldata[i] === "alarmType") {
        obj.field = coldata[i];
        obj.title = "报警类型";
        obj.align = "center";
        this.data.columnsSafetyReportDetail[0] = obj;
      } else if (coldata[i] === "alarmName") {
        obj.field = coldata[i];
        obj.title = "报警名称";
        obj.align = "center";
        this.data.columnsSafetyReportDetail[1] = obj;
      } else if (coldata[i] === "合计") {
        obj.field = "合计";
        obj.title = "合计";
        obj.align = "center";
        this.data.columnsSafetyReportDetail[coldata.length - 1] = obj;
      }
    }
  },
  mergeRowCollSpan(data) { // 行合并ok
    var zhudong = 0;
    var shigu = 0;
    var weigui = 0;
    data.forEach(item => {
      switch(item.alarmType) {
        case "主动安全报警":
          zhudong+=1;
          break;
        case "事故报警":
          shigu+=1;
          break;
        case "违规报警":
          weigui+=1;
          break;
      }
    })
    $("#report_detail_table").bootstrapTable('mergeCells', { index: 0, field: "alarmType", colspan: 0, rowspan: zhudong })
    $("#report_detail_table").bootstrapTable('mergeCells', { index: zhudong, field: "alarmType", colspan: 0, rowspan: shigu })
    $("#report_detail_table").bootstrapTable('mergeCells', { index: zhudong + shigu, field: "alarmType", colspan: 0, rowspan: weigui })
  },
  initchartsLine(data) {
    var titleName = "企业报警趋势分析";
    var legendName = ['主动安全报警', '事故报警', '违规报警', '报警平均处理时长', '处理率'];
    var name = [];
    var zhudongNumber = [];
    var shiguNumber = [];
    var weiguiNumber = [];
    var timeDifference = [];
    var alarmRate = [];
    data.forEach(item => {
      name.push(item.bightTime)
      zhudongNumber.push(item.activeNum)
      shiguNumber.push(item.accidentNum)
      weiguiNumber.push(item.illegalNum)
      timeDifference.push(item.aveHandleMin)
      alarmRate.push(item.handleLv)
    })
    charts.reportChartsLine("platform_line_chart",titleName,legendName,name,zhudongNumber,shiguNumber,weiguiNumber,timeDifference,alarmRate);
  },
  initchartsPieType(data) { // 饼图左边
    const alarmName = []
    const count = []
    for (const key in data) {
      const obj = {}
      obj.name = key
      obj.value = data[key]
      alarmName.push(key)
      count.push(obj)
    }
    // var alarmName = ["主动安全报警", "事故报警", "违规报警"];
    // var count = [
    //   {name: "主动安全报警",value: 300},{name: "事故报警",value: 230},{name: "违规报警",value: 120}
    // ];
    charts.reportChartsPie("piechart_police_total","企业报警类型分析", alarmName, count);
  },
  initchartsPieDetail(data) {
    const alarmName = []
    const count = []
    for (const key in data) {
      const obj = {}
      obj.name = key
      obj.value = data[key]
      alarmName.push(key)
      count.push(obj)
    }
    // var alarmName = [
    //   "侧翻预警",
    //   "分神驾驶报警",
    //   "前向碰撞报警",
    //   "危险路段报警",
    //   "抽烟报警",
    //   "接打电话报警",
    //   "疲劳驾驶报警",
    //   "碰撞预警",
    //   "紧急报警",
    //   "超时疲劳驾驶报警",
    //   "超时驾驶报警",
    //   "超速报警",
    //   "车距过近报警",
    //   "车道偏离报警",
    //   "驾驶人异常报警"
    // ];
    // var count = [
    //   {name: "侧翻预警",value: 30},{name: "分神驾驶报警",value: 20},{name: "前向碰撞报警",value: 10},
    //   {name: "危险路段报警",value: 20},{name: "抽烟报警",value: 20},{name: "接打电话报警",value: 20},
    //   {name: "疲劳驾驶报警",value: 30},{name: "碰撞预警",value: 30},{name: "紧急报警",value: 40},
    //   {name: "超时疲劳驾驶报警",value: 30},{name: "超时驾驶报警",value: 30},{name: "超速报警",value: 40},
    //   {name: "车距过近报警",value: 30},{name: "车道偏离报警",value: 30},{name: "驾驶人异常报警",value: 40},
    // ];
    charts.reportChartsPie("piechart_police_detail","", alarmName, count);
  },
  drawingSafetyReport(id) { // 安全报告生成/绘制
    jrequest.get(`/api/safeReport/owersSafetyReportDetails/${id}`,{}).then(res => {
      const tableData = {};
      tableData.statisticsTime = res.data.statisticsTime;
      tableData.vehicleNo = res.data.vehicleNo;
      tableData.areaName = res.data.areaName;
      tableData.platformId = res.data.platformId;
      tableData.vehicleNum = res.data.vehicleNum;
      tableData.activeNum = res.data.activeNum;
      tableData.accidentNum = res.data.accidentNum;
      tableData.illegalNum = res.data.illegalNum;
      tableData.alarmNum = res.data.alarmNum;
      tableData.handleResult = res.data.handleResult;
      tableData.handleLv = res.data.handleLv + "%";
      totalreport.data.reportTotalTableData[0] = tableData;
      totalreport.getOwersTotalTableData(); // 总表格

      totalreport.initchartsLine(res.data.safeReportBightList); // 线图
      totalreport.initchartsPieType(res.data.alarmThreeType); // 饼图 总
      totalreport.initchartsPieDetail(res.data.alarmTypeCode); // 饼图 详
      
      totalreport.getTotalTableColumns(res.data.baseMap); // 详情表格列头数据获取
      totalreport.data.safetyReportDetailData = res.data.baseMap;
      totalreport.getOwersDetailTableData(); // 详情表格
    })
  },
  deleteSafetyReport(id) {  // 安全报告删除
    JPop.dialogDel({msg:'确定删除?',operate:true}).on(success => {
        if (success) {
          jrequest.delete(`/api/safeReport/${id}`,{}).then(res => {
            if (res.data) {
              totalreport.data.searchType = 0;
              totalreport.queryTableData();
            } else {
              // alert("删除失败！");
              JPop.alert({msg:'删除失败！',type:'error'})
            }
          })
        }
    })
    // var con;
    // con = confirm("是否确认删除?");
    // if(con) {
    //   jrequest.delete(`/api/safeReport/${id}`,{}).then(res => {
    //     if (res.data) {
    //       totalreport.data.searchType = 0;
    //       totalreport.queryTableData();
    //     } else {
    //       alert("删除失败！");
    //     }
    //   })
    // }
  },
  getSelectCarTatbleData() { // 选择车辆模态框表格数据获取
    var querySelectCar = {};
    querySelectCar.page = totalreport.data.carData.page;
    querySelectCar.size = totalreport.data.carData.size;
    querySelectCar.areaId = $(".j-search-row .item").eq(0).find("input").attr("data-id") || "";
    querySelectCar.platformName = $(".platform_name select").val();
    querySelectCar.owersName = $(".owers_name select").val();
    querySelectCar.vehicleNo = $("#fp_dialog_search_vehicle_no").val().trim();
    jrequest.get("/api/vehicle",querySelectCar).then(res => {
      totalreport.initSelectCarTable(res.data,totalreport.data.columusSelectVehicleNo,res.total); // 表格初始化
    })
  },
  /**
   * 按钮操作
   */
  btnEvent() {
    $(".item.vehicle_name").hide();
    $(".item.driver_name").hide();
    $(".j-search-con.safety_report").hide(); // 初始化安全报告隐藏
    // $(".time_select").hide();
  
    $(".tab_content").on("click","div",function() { // 顶部tab切换
      var index = $(this).index();
      totalreport.data.searchType = 0;
      totalreport.data.pageNum = index + 1;
      if (totalreport.data.pageNum != totalreport.data.currentSafetyReportPage) {
        $(".j-search-con.safety_report").hide();
        $(".j-search-con.table_list").show();
      }
      $(".tab_content div").eq(index).addClass("active").siblings().removeClass("active");
      totalreport.resetQueryData();
      switch(index) {
        case 0:
          $(".item.vehicle_name").hide();
          $(".item.driver_name").hide();
          totalreport.getOwerReportTable();
          break;
        case 1:
          $(".item.vehicle_name").show();
          $(".item.driver_name").hide();
          totalreport.getVehicleReportTable();
          break;
        case 2:
          $(".item.vehicle_name").hide();
          $(".item.driver_name").show();
          totalreport.getDriverReportTable();
          break;
      }
    });
    $(".reportSearch_btn").click(() => { // 生成
      totalreport.data.searchType = 1;
      let type = $("#reportStaticTime").val();
      let owersV = $(".platform_name.item .combo-select .combo-input").val();
      let driverV = $(".driver_name.item .combo-select .combo-input").val(); // 待修改
      switch(totalreport.data.pageNum) {
        case 1:
          // if (owersV === "全部") {
          //   JPop.alert({msg:'请选择企业！'})
          //   return false;
          // }
          if (type === "月") {
            if ($("#samplingTimeM").val() === "") {
              // alert("请选择时间！");
              JPop.alert({msg:'请选择时间！'})
              return false;
            }
          } else if (type === "年") {
            if ($("#samplingTimeY").val() === "") {
              // alert("请选择时间！");
              JPop.alert({msg:'请选择时间！'})
              return false;
            }
          }
          break;
        case 2:
          if (!$("#report_vehicleS").val()) {
            // alert("请选择车辆！");
            JPop.alert({msg:'请选择车辆！'})
            return false;
          }
          if (type === "月") {
            if ($("#samplingTimeM").val() === "") {
              // alert("请选择车辆！");
              JPop.alert({msg:'请选择车辆！'})
              return false;
            }
          } else if (type === "年") {
            if ($("#samplingTimeY").val() === "") {
              // alert("请选择时间！");
              JPop.alert({msg:'请选择时间！'})
              return false;
            }
          }
          break;
        case 3:
            if (driverV === "全部") {
              // alert("请选择驾驶员！");
              JPop.alert({msg:'请选择驾驶员！'})
              return false;
            }
            if (type === "月") {
              if ($("#samplingTimeM").val() === "") {
                // alert("请选择时间！");
                JPop.alert({msg:'请选择时间！'})
                return false;
              }
            } else if (type === "年") {
              if ($("#samplingTimeY").val() === "") {
                // alert("请选择时间！");
                JPop.alert({msg:'请选择时间！'})
                return false;
              }
            }
            break;
      }
      totalreport.queryTableData();
    })
    $(".reportReset_btn").click(() => { // 列表重置
      totalreport.data.searchType = 0;
      totalreport.resetQueryData();
      totalreport.queryTableData();
    })

    $("#reportStaticTime").change(function() {
      let type = $("#reportStaticTime").val();
      if (type === "年") {
        $(".J-yearPicker-single").show();
        $(".J-yearMonthPicker-single").hide();
      } else if (type === "月") {
        $(".J-yearPicker-single").hide();
        $(".J-yearMonthPicker-single").show();
      }
    })
    // ***********   安全报告设置
    $(".return_download .return span").click(() => { // 返回
      $(".j-search-con.safety_report").hide();
      $(".j-search-con.table_list").show();
      totalreport.data.columnsSafetyReportDetail = [];
      totalreport.data.safetyReportDetailData = [];
      // charts.reportChartsLine().dispose();
    })

    $("#report_vehicleS").click(function() { // 选择车牌号input点击
      $("#carTable").show();
      var isReset = $("#report_vehicleS").val();
      if (!isReset) {
        totalreport.data.carData.page = 1;
        totalreport.data.carData.size = 5;
        totalreport.getSelectCarTatbleData();
      }
    })
    /**
     * 模态框操作
     */
    $("#carSure").click(function() { // 模态框确定
      var chooseCard = $('#dialog_table').bootstrapTable('getSelections');//获取选择行数据
      if (chooseCard.length === 0) {
        // alert("请选择车辆！");
        JPop.alert({msg:'请选择车辆！'})
        return false;
      } else {
        var carVehicle = chooseCard[0].vehicleNo;
        $("#report_vehicleS").val(carVehicle);
        $("#carTable").hide();
      }
    })
    $(".close-div").click(function() { // 关闭
      $("#carTable").hide();
      $("#fp_dialog_search_vehicle_no").val("");
    })
    $("#carCancel").click(function() { // 取消
      $("#carTable").hide();
      $("#fp_dialog_search_vehicle_no").val("");
    })
    $("#fp_dsearch").click(function() { // 选择车辆查询
      totalreport.data.carData.page = 1;
      totalreport.data.carData.size = 5;
      totalreport.getSelectCarTatbleData();
    })
    $("#fp_dreset").click(function() { // 选择车辆重置
      $("#fp_dialog_search_vehicle_no").val("");
      $("#dialog_table").bootstrapTable('uncheckAll');
    })
  }
}

$(function() {
  window.operateEventsPlat = {
    'click #table_detail': function (e, value, row, index) { // 企业详情
      totalreport.data.currentSafetyReportPage = 1; // 用以确定点击那个详情按钮
      $(".j-search-con.safety_report").show();
      $(".j-search-con.table_list").hide();
      let id = row.id;
      totalreport.drawingSafetyReport(id);
    },
    'click #table_delete': function (e, value, row, index) { // 企业删除
      var id = row.id;
      totalreport.deleteSafetyReport(id);
    }
  }
  window.operateEventsVehicle = {
    'click #table_detail': function (e, value, row, index) { // 车辆详情
      totalreport.data.currentSafetyReportPage = 2;
      $(".j-search-con.safety_report").show();
      $(".j-search-con.table_list").hide();
      let id = row.id;
      totalreport.drawingSafetyReport(id);
    },
    'click #table_delete': function (e, value, row, index) { // 车辆删除
      var id = row.id;
      totalreport.deleteSafetyReport(id);
    }
  }
  window.operateEventsDriver = {
    'click #table_detail': function (e, value, row, index) { // 司机详情
      totalreport.data.currentSafetyReportPage = 3;
      $(".j-search-con.safety_report").show();
      $(".j-search-con.table_list").hide();
      let id = row.id;
      totalreport.drawingSafetyReport(id);
    },
    'click #table_delete': function (e, value, row, index) { // 司机删除
      var id = row.id;
      totalreport.deleteSafetyReport(id);
    }
  }
  totalreport.initPage(); // 页面初始化
})